package com.andytest.addservice.service.impl;

import com.andytest.api.service.AddService;
import org.springframework.util.StopWatch;

/**
 * @Author: Andy
 * @Date: 2021年11月10日 7:09
 * @Description: 加法服务的实现
 */
public class AddServiceImpl implements AddService {
    public int add(int a, int b) {
        StopWatch sw = new StopWatch();
        sw.start("A");
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            throw new RuntimeException("Unexpected interrupt", e);
        }
        sw.stop();
        sw.start("B");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException("Unexpected interrupt", e);
        }
        sw.stop();
        System.out.println("AddService");
        System.out.println(sw.prettyPrint());
        System.out.println("AddService2");
        return a + b;
    }
}
